import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import tailwindcss from "@tailwindcss/vite";

const env = loadEnv("development", process.cwd());
const proxyUrl = env.VITE_PROXY_URL;
// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue({
      template: {
        compilerOptions: {
          isCustomElement: (tag) =>
            [
              "calendar-date",
              "calendar-month",
              "calendar-range",
              "cap-widget",
            ].includes(tag),
        },
      },
    }),
    tailwindcss(),
  ],
  resolve: {
    alias: {
      "@": "/src",
    },
  },
  server: {
    proxy: {
      "/api": {
        target: proxyUrl,
        changeOrigin: true,
        secure: false,
      },
      "/cap": {
        target: proxyUrl,
        changeOrigin: true,
        secure: false,
      },
    },
  },
});
